<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */

namespace Plugin\File\Service;

use Plugin\File\Repository\RdFileVoiceRepository;
use App\Service\IService;

/**
 * 音频服务类
 */
final class RdFileVoiceService extends IService
{
    public function __construct(
        protected readonly RdFileVoiceRepository $repository,
        protected readonly VoiceService $voiceService
    ) {}

    public function create(array $data): mixed
    {
        $requestData = [
            "Text" => $data['text'],
            "SessionId" => strval(time()),
            "Volume" => 10,
            "Speed" => 0
        ];
        $path = $this->voiceService->saveVoice($requestData);
        return parent::create([
            'file' => $path,
            'text' => $data['text'],
            'type' => $data['type']
        ]);
    }

    public function play($path)
    {

    }
}